package com.mzwise.tunnel.service;

import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.material.WxMediaImgUploadResult;

import java.io.*;
import java.net.HttpURLConnection;
import java.net.URISyntaxException;
import java.net.URL;

/**
 * 媒体相关工具
 */
public class TunnelMpMaterial {

    /**
     * 公众号上传图片
     * @param logoImg
     * @param wxService
     */
    public static String uploadImage(String logoImg, WxMpService wxService) throws WxErrorException {
        File file = new File(logoImg);
        WxMediaImgUploadResult wxMediaUploadResult = wxService.getMaterialService().mediaImgUpload(file);
        return wxMediaUploadResult.getUrl();
    }
}
